package com.rongke.web;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.rongke.commons.JsonResp;
import com.rongke.model.SelectiveGoods;
import com.rongke.service.SelectiveGoodsService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

/**
 * @SelectiveGoodsController
 * @精选定制商品Controller
 * @version : Ver 1.0
 */
@RestController
@RequestMapping(value="/api/selectiveGoods")
@Transactional
@CrossOrigin
public class SelectiveGoodsController {
    private Logger log = Logger.getLogger(this.getClass());
    @Autowired
    private SelectiveGoodsService selectiveGoodsService;

    /**
     * @添加精选定制商品
     * @param selectiveGoods
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/add", method = RequestMethod.POST)
    public JsonResp addSelectiveGoods(@RequestBody SelectiveGoods selectiveGoods){
        log.debug("添加精选定制商品");
        selectiveGoodsService.insert(selectiveGoods);
        return JsonResp.ok(selectiveGoods);
    }





    /**
     * @修改精选定制商品
     * @param selectiveGoods
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/update", method = RequestMethod.POST)
    public JsonResp updateSelectiveGoods(@RequestBody SelectiveGoods selectiveGoods){
        log.debug("修改精选定制商品");
        selectiveGoodsService.updateById(selectiveGoods);
        return JsonResp.ok(selectiveGoods);
    }




    /**
     * @根据id查找精选定制商品
     * @param id
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/selectOne", method = RequestMethod.GET)
    public JsonResp selectSelectiveGoods(Long id){
        log.debug("查找精选定制商品");
        SelectiveGoods selectiveGoods = selectiveGoodsService.selectById(id);
        return JsonResp.ok(selectiveGoods);
    }





}
